# class Stu(object):
#     __stu_num = 0
#     name = 222
#     def __init__(self, name):
#         self.name = name
#         self.add_stu(self)
#     @classmethod                           #类方法：只访问类变量，不访问实例变量      只能由类调用
#     def add_stu(cls, obj):
#         if obj.name:
#             cls.__stu_num += 1
#             print(cls.__stu_num)
#     @staticmethod                          #静态方法：不访问类变量，不访问实例变量        #只能由实例调用
#     def speaking(self):
#         print('stu speaking')
# p1 = Stu('111')
# p2 = Stu('222')
# p3 = Stu('333')
# #Stu.add_stu(Stu)
# p1.speaking(p1)



# class Stu(object):                      #属性方法
#     def __init__(self, name):
#         self.name = name
#     @property                      #得到
#     def fly(self):
#         print('flying')
#     @fly.setter                      #可以改函数参数
#     def fly(self,num):
#         print('not flying')
#         print(num)
#     @fly.deleter                   #可以删函数
#     def fly(self):
#         print('del ')
# p = Stu('111')
# p.fly
# p.fly = 2
# del p.fly




# class Person(object):                          #反射
#     def __init__(self, name, age):
#         self.name, self.age = name, age
#     def walk(self):
#         print(self.name, 'is walking')
# def talk(self):
#     print(self.name, 'is  talking')
# p = Person('yyt', 22)
# if hasattr(p, 'age'):                                #查是否有p的age
#     print(getattr(p, 'age'))                           #显示p的age
# else:
#     print('dont have')
# setattr(p, 'sex', 'M')                                #添加p的实例属性
# print(p.sex)
# setattr(Person, 'speak', talk)
# p.speak()
# print(p.age)
# delattr(p, 'age')                                  #删除p的实例属性


# import pythontip                                    #从其他文件映射调用函数
# if hasattr(pythontip, 'talk'):
#     a = getattr(pythontip, 'talk')
#     a()
#
#     setattr(pythontip, 'age', 22)
#     print(pythontip.age)



# import importlib                                 #动态导入 官方推荐
# importlib.import_module('pythontip')



#__import__('pythontip')                          #解释器自用   官方不推荐



# class User:                                        #反射的小妙用
#     def login(self):
#         print('登录')
#     def register(self):
#         print('注册')
#     def save(self):
#         print('储藏')
# u = User()
# while 1:
#     choose = input('>>:').strip()
#     if hasattr(u, choose):
#         func = getattr(u, choose)
#         func()
#     else:
#         print('输入错误')




# class School:                                           #有str输出str 再看repr 再输出迭代器
#     def __init__(self, name, addr, type):
#         self.name = name
#         self.addr = addr
#         self.type = type
#     def __repr__(self):
#         return 'School(%s,%s)' %(self.name, self.addr)
#     def __str__(self):
#         return '(%s,%s)' %(self.name, self.addr)
# s1=School('小猿圈', '北京', '私立')
# print('from repr: ', repr(s1))
# print('from str: ', str(s1))
# print(s1)



# class Person:                                #析构方法
#     def __init__(self, name ,age):
#         self.name = name
#         self.age = age
#
#     def __del__(self):
#         print('shanchu')
#
# p =Person('yyt', 22)
# print('2222')
# print('2222')
# del p
# print('2222')
# print('2222')



# class Person(object):
#     lis = []
#     ins = None
#     def __init__(self, name):
#         self.name = name
#     def add_work(self, job):
#         self.lis.append(job)
#         print('%s,收到工作%s，添加到打印机，总工作数%s' % (self.name, job, len(self.lis)))
#     def __new__(cls, *args, **kwargs):
#         if cls.ins == None:             #第一次实例化时是None进行，后面的都不是真正的实例化
#             obj = object.__new__(cls)     #实例化过程    把实例化的对象存在cls.ins
#
#             cls.ins = obj          #把实例化好的对象存下来
#         return cls.ins            #以后的每次实例化，直接返回第一次的对象
#                      #再上次的实例对象基础上  再执行__Init_
# p1 = Person('yy1')
# p2 = Person('yy2')
# p3 = Person('yy3')
# p1.add_work('aaaaaa')
# p2.add_work('bbbbbb')
# p3.add_work('cccccc')




# class Person:
#     def __init__(self, name, age):
#         self.name = name
#         self.age = age
# p = Person('yyt', 22)
# print(p.name, p.age)
# def __init__(self, name, age):
#     self.name = name
#     self.age = age
# dog = type('Dog', (), {'__init__':__init__})
# d1 = dog('xxx', 2)
# print(d1.name, d1.age)




class QqConError(BaseException):
    def __init__(self, msg):
        self.msg = msg

    def __str__(self):
        return self.msg

while 1 :
    try:
        a = input('>:')
        print(a)
        raise QqConError('cuowu1')
    except QqConError as e:
        print('cuowu', e)



